
PREFIX=i586-elf-

AS=nasm
CC=${PREFIX}gcc
LD=${PREFIX}ld

CCFLAGS=-std=c99 -c -Wall -Wextra -Werror -nostdlib -nostartfiles -nodefaultlibs -fno-builtin
LDFLAGS=-T linker.ld
NASMFLAGS=-f elf

OBJS = loader.o prekernel.o common.o kstring.o kscreen.o gdt.o

all:${OBJS}
	${LD} ${LDFLAGS} ${OBJS} -o prekernel.bin
	cat  stage1 stage2 pad prekernel.bin > floppy.img

clean:
	rm *.o *.bin *.img

loader.o:loader.s
	${AS} ${NASMFLAGS} -o $@ $<
	
prekernel.o:prekernel.c
	${CC} ${CCFLAGS} -o $@ $<

common.o:common.c
	${CC} ${CCFLAGS} -o $@ $<

kstring.o:kstring.c
	${CC} ${CCFLAGS} -o $@ $<
	
kscreen.o:kscreen.c
	${CC} ${CCFLAGS} -o $@ $<
	
gdt.o:gdt.c
	${CC} ${CCFLAGS} -o $@ $<